require("../../resource/js/htmlToWxml.js"), require("../../resource/js/images.js");

var t = getApp();

Page({
    data: {
        id: 0,
        ordertype: 1
    },
    onLoad: function(e) {
        wx.setNavigationBarTitle({
            title: "经纪人发布"
        });
        var a = this;
        if (a.data.id > 0) a.data.id; else {
            e.id;
            a.data.id = e.id;
        }
        wx.getStorageSync("userInfo").sessionid ? a.initpage() : t.util.getUserInfo(function() {
            console.log("tmmmrrrr"), a.initpage();
        });
    },
    initpage: function() {
        var e = this, a = wx.getStorageSync("userInfo"), n = e.data.ordertype;
        t.util.request({
            url: "entry/wxapp/myletpublist",
            data: {
                ordertype: n,
                sessionid: a.sessionid,
                uid: a.memberInfo.uid
            },
            success: function(t) {
                t.data.message.errno || (t.data.data.intro.maincolor || (t.data.data.intro.maincolor = "#3274e5"), 
                wx.setNavigationBarColor({
                    frontColor: "#ffffff",
                    backgroundColor: t.data.data.intro.maincolor,
                    animation: {
                        duration: 400,
                        timingFunc: "easeIn"
                    }
                }), e.setData({
                    list: t.data.data.list,
                    ordertype: n
                }));
            }
        });
    },
    onReady: function() {},
    tabClick: function(e) {
        var a = this, n = e.currentTarget.id, o = wx.getStorageSync("userInfo");
        t.util.request({
            url: "entry/wxapp/myletpublist",
            data: {
                ordertype: n,
                sessionid: o.sessionid,
                uid: o.memberInfo.uid
            },
            success: function(t) {
                t.data.message.errno || a.setData({
                    list: t.data.data.list,
                    ordertype: n
                });
            }
        });
    },
    delOrder: function(e) {
        var a = this, n = e.currentTarget.dataset.id, o = wx.getStorageSync("userInfo");
        wx.showModal({
            title: "订单取消",
            content: "确认取消订单？",
            success: function(e) {
                e.confirm && t.util.request({
                    url: "entry/wxapp/delOrder",
                    data: {
                        id: n,
                        sessionid: o.sessionid,
                        uid: o.memberInfo.uid
                    },
                    success: function(t) {
                        console.log(t), a.onLoad();
                    },
                    fail: function(t) {
                        console.log(t);
                    }
                });
            }
        });
    },
    RepayOrder: function(e) {
        var a = this, n = e.currentTarget.dataset.id, o = wx.getStorageSync("userInfo");
        wx.showModal({
            title: "订单支付",
            content: "是否确认订单？",
            success: function(e) {
                e.confirm && t.util.request({
                    url: "entry/wxapp/repay",
                    data: {
                        id: n,
                        sessionid: o.sessionid,
                        uid: o.memberInfo.uid
                    },
                    success: function(t) {
                        t.data && t.data.data && wx.requestPayment({
                            timeStamp: t.data.data.timeStamp,
                            nonceStr: t.data.data.nonceStr,
                            package: t.data.data.package,
                            signType: "MD5",
                            paySign: t.data.data.paySign,
                            success: function(t) {
                                a.onLoad();
                            },
                            fail: function(t) {}
                        });
                    },
                    fail: function(t) {
                        console.log(t);
                    }
                });
            }
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    checkuser: function(e) {
        var e = e, a = wx.getStorageSync("userInfo");
        return a && a.memberInfo.uid ? void t.util.request({
            url: "entry/wxapp/checkuserinfo",
            data: {
                sessionid: a.sessionid,
                uid: a.memberInfo.uid
            },
            success: function(t) {
                0 == t.data.data.error ? (console.log(e), e.doServices()) : 2 == t.data.data.error && e.doServices();
            }
        }) : (t.util.getUserInfo(), !1);
    }
});